<?php
error_reporting(0);
ini_set('memory_limit', '1000M');
set_time_limit(0);


/** 
 *  mapper8.php
 *      input:格式：mapred8输出 (json1\tjson2\t...)尤其要注意其中的weight字段
 *      handle:生成sql
 *      output:sql语句--INSERT INTO `broker_check` VALUES ('1', ...);
 * @created 2016-03-09
 * @by delia
 */
$time = time();
while (($line_json = fgets(STDIN)) !== false) {   //line_json=>source_url\tjson格式
    if($nu==0){
	echo "INSERT INTO broker_check(phone,add_time,update_time,source) VALUES";
	$nu = 1;
    }
    else{
	echo ",\n";
	$nu+=1;
    }
    $line_json = trim($line_json);
    if (empty($line_json))
        continue;
    list($phone, $source) = explode("\t", $line_json); 
    echo " ('".$phone."','".
	$time."','".$time."','".
	$source."')";	
    if($nu==19){
    	echo ";\n";
        $nu=0;
     }
}
echo ";\n";	
?>

